#include <iostream>
using namespace std;


#include "IncidenceGraph.h"
#include "Dijkstra.h"
#include "GraphReader.h"


void main(int argc, char** argv)
{
	auto g = IncidenceGraph();
	auto reader = GraphReader(g);

	reader.Read("5x5_graph_al.graph");

	cout << g.VertexCount() << " vertices, " << g.EdgeCount() << " edges" << endl;
	auto v = g.GetVertices();
	for (auto it = v.begin(); it != v.end(); it++) {
		cout << "vertex " << *it << " (" << g.EdgeCount(*it) << " neighbors)" << endl;

		auto e = g.GetEdges(*it);
		for (auto itt = e.begin(); itt != e.end(); itt++) {
			cout << "    " << itt->i << " -> " << itt->j << " (" << itt->weight << ")" << endl;
		}
	}

	int source = 1;
	auto dijkstra = Dijkstra(g);

	cout << "shortest paths from vertex " << source << endl;
	dijkstra.CalculateShortestDistances(source);
	for (auto it = v.begin(); it != v.end(); it++) {
		auto path = dijkstra.GetShortestPath(*it);
		cout << "    " << source << " -> " << *it << " (distance " << dijkstra.GetDistance(*it) << "):  ";
		for (auto itt = path.begin(); itt != path.end(); itt++) {
			cout << itt->current << "  ";
		}
		cout << endl;
	}

	getchar();
}